import java.io.*;
//前缀和
//测试链接 https://www.nowcoder.com/practice/acead2f4c28c401889915da98ecdc6bf
public class PrefixSum {
    public static long[] arr = new long[100001];
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StreamTokenizer in = new StreamTokenizer(br);
        PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));

        while(in.nextToken() != StreamTokenizer.TT_EOF){
            int n = (int)in.nval;
            in.nextToken();
            int m = (int)in.nval;
            in.nextToken();
            long sum = 0;
            for(int i = 1; i <= n; i++){
                int num = (int)in.nval;
                sum += num;
                arr[i] = sum;
                in.nextToken();
            }

            for(int i = 0; i < m; i++){
                int left = (int)in.nval;
                in.nextToken();
                int right = (int)in.nval;
                in.nextToken();

                long ret = arr[right] - arr[left-1];
                out.println(ret);
            }
        }
        out.flush();
        br.close();
        out.close();
    }
}
